package natsx

import (
	"context"

	"gitee.com/lyuanbo/stock-plus/pkg/logger"
	"github.com/nats-io/nats.go"
	"go.uber.org/zap"
)

// New 返回一个nats连接
func New(ctx context.Context, url string, user string, password string, logger *logger.Logger) *nats.Conn {
	nc, err := nats.Connect(url, nats.UserInfo(user, password))
	if err != nil {
		logger.Warn(ctx, "中间件: nats连接失败", zap.Error(err))
		return nil
	}
	return nc
}
